package drawlots.xzh.com.myapplication;

import android.app.Dialog;
import android.content.Intent;
import android.net.Uri;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.FrameLayout;

public class MainActivity extends AppCompatActivity implements BlankFragment.OnFragmentInteractionListener{

    private FrameLayout frameLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        LogUtils.log(getClass().getSimpleName()+"  onCreate");
        initView();
    }

    private void initView() {
        frameLayout = findViewById(R.id.frame_layout);
        FragmentManager manager = getSupportFragmentManager();
        FragmentTransaction transaction = manager.beginTransaction();
        BlankFragment fragment = BlankFragment.newInstance("KAIXIN","JIAYOU");
        transaction.replace(R.id.frame_layout,fragment);
        transaction.commit();

    }

    @Override
    protected void onPostResume() {
        super.onPostResume();
        LogUtils.log(getClass().getSimpleName()+"  onPostResume");
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        LogUtils.log(getClass().getSimpleName()+"  onNewIntent");
    }



    @Override
    protected void onStart() {
        super.onStart();
        LogUtils.log(getClass().getSimpleName()+"  onStart");
    }

    @Override
    protected void onRestart() {
        super.onRestart();
        LogUtils.log(getClass().getSimpleName()+"  onRestart");
    }

    @Override
    protected void onResume() {
        super.onResume();
        LogUtils.log(getClass().getSimpleName()+"  onResume");
    }

    @Override
    protected void onPause() {
        super.onPause();
        LogUtils.log(getClass().getSimpleName()+"  onPause");
    }

    @Override
    protected void onStop() {
        super.onStop();
        LogUtils.log(getClass().getSimpleName()+"  onStop");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        LogUtils.log(getClass().getSimpleName()+"  onDestroy");
    }

    public void showDialog(View view) {

        Dialog dialog = new Dialog(this);
        dialog.setContentView(R.layout.dialog_layout);
        dialog.show();

    }

    @Override
    public void onFragmentInteraction(Uri uri) {

    }

    public void nextActivity(View view) {
        Intent intent = new Intent(this,SecondActivity.class);
        startActivity(intent);
    }
}
